﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Wicresoft.UnifyShow.Business;
using Microsoft.Practices.Unity;
using Wicresoft.UnifyShow.Portal.ViewModels;

namespace Wicresoft.UnifyShow.Portal.Controllers
{
    public class BESAlertPartialViewController : BaseController
    {

        private IAlert alert;

        protected override void Dispose(bool disposing)
        {
            ((IDisposable)alert).Dispose();
        }

        [InjectionConstructor]
        public BESAlertPartialViewController(IAlert alert)
        {
            this.alert = alert;
        }

        public ActionResult AlertPartialView(int siteID, int serviceID, int? deviceID, int page = 1, string sort = "Timestamp", string sortDir = "Descending")
        {
            const int pageSize = 10;
            Decimal totalCount = 0;
            List<AlertDetailAndDevice> listAlert;
            listAlert = alert.GetAlertBySiteBSAndDeviceID(siteID, serviceID, deviceID, out totalCount, pageSize, page, sort, sortDir);
            return PartialView(new PagedAlertModel()
            {
                Alerts = listAlert,
                PageNumber = page,
                PageSize = pageSize,
                TotalRows = totalCount
            });
        }

    }
}
